<!doctype html>
<html>

<head>
	<meta charset="UTF-8">
	<title>个人中心</title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	{% include 'public/static_top.html' %}
	<style type="text/css">
		/*用户信息*/
		.userinfo {
			margin-bottom: 20px;
		}
		.headimage {
			width: 30%;
			margin-left: 35%;
			margin-top: 10px;
			border-radius: 50%;
		}
		.nickname {
			text-align: center;
			color: #000000;
			font-size: 1.5em;
			margin-top: 5px;
		}
		
		#scanCode {
			margin-top: 20px;
		}
	</style>
</head>

<body>
	<div class="userinfo">
		<img class="headimage" src="{{ userinfo.headimgurl }}" />
		<p class="nickname">{{ userinfo.nickname }}</p>
	</div>

    <ul class="mui-table-view">
		<li class="mui-table-view-cell"><a href="{{ url('user:bookbill') }}" class="mui-navigate-right">借书单</a></li>
	</ul>
	
	<ul class="mui-table-view">
		<li class="mui-table-view-cell"><a href="{{ url('user:borrowing') }}" class="mui-navigate-right">未还图书</a></li>
		<li class="mui-table-view-cell"><a href="{{ url('user:all_borrow') }}" class="mui-navigate-right">借阅记录</a></li>
	</ul>

	{% if userinfo.operation == '1' %}
    <div class="mui-content-padded">
		<button type="button" class="mui-btn mui-btn-block mui-btn-primary" id="scanCode">扫码 借/还</button>
	</div>
	{% endif %}
	
	<!--底部菜单栏-->
	{% include 'public/footer.html' %}
	

	<script type="text/javascript" src="{{ static('js/footer.js') }}" ></script>
	<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" ></script> 
	<script type="text/javascript">
        document.querySelectorAll('nav.mui-bar>a.mui-tab-item')[2].classList.add('mui-active');
	{% if userinfo.operation == '1' %}
        wx.config({
            debug: false,
            appId: '{{appId}}',
            timestamp: {{sign.timestamp}},
            nonceStr: '{{sign.nonceStr}}',
            signature: '{{sign.signature}}',
            jsApiList: [ 'scanQRCode',]
        });
        document.querySelector('button#scanCode').addEventListener('click', function () {
			console.log('success');
            wx.scanQRCode({
                needResult: 1,
                desc: 'scanQRCode desc',
                success: function (res) {
                    result = res.resultStr;
                    window.location.href = "{{ url('user:operation') }}" + "?result=" + result;
                }
            });
        });
	{% endif %}
	</script>
</body>

</html>
